<!DOCTYPE HTML>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<!-- load the built-in JS library -->
		<script type="text/javascript" src="/gotalk/gotalk.js"></script>
	</head>
	<body style="white-space:pre;font-family:monospace"><button>Send request</button>
	<script>
	// create a connection (automatically reconnects as needed)
	let c = gotalk.connection()
		.on('open', async() => log(`connection opened\n`))
		.on('close', reason => log(`connection closed (reason: ${reason})\n`))
	// make out button send a request
	document.body.firstChild.onclick = async () => {
		let res = await c.requestp('test/message', 'hello ' + new Date())
		log(`reply: ${JSON.stringify(res, null, 2)}\n`)
	}
	function log(message) {
		document.body.appendChild(document.createTextNode(message))
	}
	</script>
	</body>
</html>
